package hawk.example.jdk.serviceLoader.impl;

import java.util.ServiceLoader;

import hawk.example.jdk.serviceLoader.Cipher;

public class ServiceLoaderDemo {
    public static ServiceLoader<Cipher> cipherLoader = ServiceLoader.load(Cipher.class);

    public static void main(String[] args) {
        int strength = cipherLoader.findFirst().get().strength();
        System.out.println(strength);

        int strength2 = cipherLoader.stream().filter(desc -> desc.type() == CaesarCipher.class).findFirst()
                .map(ServiceLoader.Provider::get).get().strength();
        System.out.println(strength);
    }
}
